home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Hardcore Visual Basic 5.0 (2nd Edition)
/
Hardcore Visual Basic 5.0 - Second Edition (1997)(Microsoft Press).iso
/
Code
/
Goodies
/
CallBack
/
SOURCE
/
ERRINFO.CPP
< prev
next >
Wrap
C/C++ Source or Header
|
1995-10-03
|
2KB
|
78 lines
/*
* Visual Basic Callback Server Source
*
* (c) Copyright Microsoft Corp. 1995 All Rights Reserved
*/
#include "hostenv.h"
#include "ErrInfo.h"
/**************************Implementation of CSupportErrorInfo class****************************/
CSupportErrorInfo::CSupportErrorInfo()
{
m_refs = 0;
m_Desc = SysAllocStringLen(NULL, 0);
m_pcerrinfo = NULL;
}
CSupportErrorInfo::~CSupportErrorInfo()
{
if (m_Desc)
SysFreeString(m_Desc);
if (m_pcerrinfo)
m_pcerrinfo->Release();
}
STDMETHODIMP
CSupportErrorInfo::QueryInterface(REFIID riid, void FAR* FAR* ppvObj)
{
if ( IIDOK(IUnknown) || IIDOK(ISupportErrorInfo) )
{
*ppvObj = this;
}
else
{
*ppvObj = NULL;
return ResultFromScode(E_NOINTERFACE);
}
AddRef();
return NOERROR;
}
STDMETHODIMP_(ULONG)
CSupportErrorInfo::AddRef(void)
{
return ++m_refs;
}
STDMETHODIMP_(ULONG)
CSupportErrorInfo::Release(void)
{
if(--m_refs == 0)
{
delete this;
return 0;
}
return m_refs;
}
STDMETHODIMP
CSupportErrorInfo::InterfaceSupportsErrorInfo(REFIID riid)
{
HRESULT hr;
IErrorInfo FAR* perrinfo;
if ( !m_pcerrinfo )
{
if ( (hr = CreateErrorInfo(&m_pcerrinfo)) != NOERROR )
{
m_pcerrinfo = NULL;
return hr;
}
m_pcerrinfo->SetSource(OLESTR("INIManager"));
}
m_pcerrinfo->SetDescription(m_Desc);
//If we get this far, this will always work, no error check needed.
m_pcerrinfo->QueryInterface(IID_IErrorInfo, (void FAR* FAR*) &perrinfo);
hr = SetErrorInfo(0, perrinfo);
perrinfo->Release();
return hr;
}